package ciyuan.Item.SkillBook;

import ciyuan.Item.ItemGroups;
import ciyuan.Item.TypeInterface.SkillBookType;
import ciyuan.Player.Skill.SkillUtils;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;

public class JungleSpirit extends SkillBookType {

    public JungleSpirit() {
        super(new Properties().tab(ItemGroups.SkillBook));
    }

    @Override
    public void keyDown(PlayerEntity playerEntity) {
        SkillUtils.setSkillColdInterval(playerEntity, this, 25 * 1000);

        playerEntity.addEffect(new EffectInstance(Effects.INVISIBILITY, 100, 0));
        playerEntity.addEffect(new EffectInstance(Effects.MOVEMENT_SPEED, 100, 4));
        SkillUtils.THREAD_POOL_EXECUTOR.execute(new Runnable() {
            @Override
            public void run() {
                for (int i=0;i<5;i++) {
                    playerEntity.setHealth(playerEntity.getHealth()+(float)(playerEntity.getMaxHealth()*0.05));
                    SkillUtils.sleep(1000);
                }
            }
        });

        SkillUtils.saveSkillCastTime(playerEntity,this);
    }

    @Override
    public String getSkillCastName() {
        return "JungleSpirit";
    }

    @Override
    public ITextComponent getSkillDescription() {
        return new TranslationTextComponent("ciyuan.skill.desc.19");
    }

    @Override
    public ITextComponent getSkillName() {
        return new TranslationTextComponent("ciyuan.skill.name.19");
    }
}
